<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/HomeTemplate.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                >
    <ui:define name="body">
        <div class="main-container" >
      <p:tabMenu id="tab1" model="#{dynamicMenu.getSimpleMenuModel(1)}" style="width: 90%"  />
      
        <h:form id="form" style="width: 1200px" >  
            <p:panel style="border-bottom: none; width: 1200px" >  
            <p:fieldset legend="Filter"  >  
         

                <h:panelGrid columns="8"  style="border-bottom-width: 0px; border-spacing: 0px; ">  
                
                <h:outputText value="SKU:" />  
                <p:inputText id="skuFilter" value="#{inventoryBean.param}" style="width:150px" >
                    <f:ajax render="dataTable" event="keyup" listener="#{inventoryBean.handleCityChange('InInventory.findBySku', 'sku')}" ></f:ajax>  
                </p:inputText> 
                
                <h:outputText value="Product:" />                
                <p:selectOneMenu value="#{classBean.param}" id="product" >
                    <f:selectItem itemLabel="Select" itemValue="" />
                    <f:selectItems value="#{lineBean.lines}" var="line"
                                   itemLabel="#{line.description}" itemValue="#{line.inLinePK.idLine}"/>
                    <!--<p:ajax update="type" listener="#{classBean.handleClassChange('InClass.findByIdLine', 'idLine')}"  ></p:ajax>-->
                    <f:ajax render="dataTable" event="keyup" listener="#{inventoryBean.handleCityChange('InInventory.findByI', 'sku')}" ></f:ajax>  
                </p:selectOneMenu>
                
                  <h:outputText value="Type:" />                
                  <p:selectOneMenu value="#{classBean.param}" id="type" >
                    <f:selectItem itemLabel="Select Type" itemValue="" />
                    <f:selectItems value="#{classBean.classes}" var="classe"
                                   itemLabel="#{classe.description}" itemValue="#{classe.description}"/>
                    <p:ajax update="ride" listener="#{classBean.handleClassChange('InClass.findByDescription', 'description')}"  ></p:ajax>
                </p:selectOneMenu>
                  
                  <h:outputText value="Ride:" /> 
                  <p:selectOneMenu   id="ride"   >
                    <f:selectItem itemLabel="Select Ride" itemValue="" />
                    <f:selectItems value="#{classBean.classes}" var="class2"
                                   itemLabel="#{class2.description2}" itemValue="#{class2.description2}"/>  
                </p:selectOneMenu>
                 
                   
                   

            </h:panelGrid>  

           </p:fieldset>  

            <h:panelGrid columns="5" cellpadding="5" style="border-bottom-width: 30px">  
                <p:commandButton  value="Filter" icon="ui-icon-search"   ajax="false" action="#{inventoryBean.handleCityChange('', param)}"></p:commandButton> 
                <p:commandButton  value="PDF"  > </p:commandButton> 
                <p:commandButton  value="Excel"  > </p:commandButton>
                <p:commandButton value=" Place Order " action="placeOrder" ajax="false" style="color: #0072C6;" >
                 </p:commandButton> 
              
            
            </h:panelGrid>

</p:panel>
            <p:dataTable id="dataTable" var="inventory" value="#{inventoryBean.inventories}" widgetVar="inventoryTable" paginator="true"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks}
                         {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" paginatorPosition="bottom" editable="true" editMode="cell"
                         style="width: 1200px">  
                         <p:column >  
                    <f:facet name="header">  
                        GI SKU 
                    </f:facet>  

                    <h:outputText value="#{inventory.sku}" />  

                </p:column>  
                <p:column headerText="Picture">  

<h:outputLink value="#{inventory.idCatalog.link}" target="_blank">
  <img src="resources/img/icons/gears.png"  />
</h:outputLink>
                    </p:column>  

                <p:column headerText="Model Name">  
                    <h:outputText value="#{inventory.idCatalog.modelName}" />  
                </p:column> 
                <p:column headerText="Model Year">  
                    <h:outputText value="#{inventory.idBrand.description}" />  
                </p:column> 

                <p:column headerText="Color">  
                    <h:outputText value="#{inventory.idColor.description}" />  
                </p:column>  

                <p:column headerText="Size" >  
                    <h:outputText value="#{inventory.idSize.description}" />  
                </p:column>  

                <p:column headerText="Price (TRY)">  
                    <h:outputText value="#{inventory.purchasePrice}" />  
                </p:column> 

                <p:column headerText="Quantity Available">  
                    <h:outputText value="100" />  
                </p:column>  

                <p:column headerText="Order Quantity" >  
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{inventory.salePrice}" />
                        </f:facet>
                        <f:facet name="input">
                            <h:inputText value="#{inventory.salePrice}"/>
                        </f:facet>
                    </p:cellEditor>
                </p:column>

                <f:facet name="footer">  
                    In total there are #{inventoryBean.inventories.size()} Items.  
                </f:facet>  

            </p:dataTable> 

   
        </h:form>  
        </div>      
    </ui:define>
</ui:composition>

